﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using X23.Model;

namespace X23.EFCore.Repository
{

    public interface IRepository<T> where T : BaseAuditedEntity
    {
        Task<bool> DeleteListAsync(Expression<Func<T, bool>> predicate, bool isPhysicalDelete = false);
        Task<bool> AddListAsync(List<T> entities);
        Task<bool> AddAsync(T entity);
        Task<bool> UpdateAsync(T entity);
        Task<T> GetByIdAsync(object id);
        Task<bool> DeleteAsync(object id, bool isPhysicalDelete = false);
        Task<IQueryable<T>> GetAllAsync(bool ignore = false);

        /// <summary>
        /// 可读写
        /// </summary>
        /// <param name="ignore"></param>
        /// <returns></returns>
        IQueryable<T> Table(bool ignore = false);
        /// <summary>
        /// 只可读数据
        /// </summary>
        /// <param name="ignore"></param>
        /// <returns></returns>
        IQueryable<T> TableNoTracking(bool ignore = false);



        ///// <summary>
        ///// 增加一条记录
        ///// </summary>
        ///// <param name="entity">实体模型</param>
        //bool Add(T entity);

        ///// <summary>
        ///// 更新一条记录
        ///// </summary>
        ///// <param name="entity">实体模型</param>
        //bool Update(T entity);


        ///// <summary>
        ///// 通过Id获取实体
        ///// </summary>
        ///// <param name="id">Id</param>
        ///// <returns></returns>
        //T GetById(object id);

        ///// <summary>
        ///// 删除一条记录
        ///// </summary>
        ///// <param name="id">实体模型</param>
        ///// <param name="isPhysicalDelete">是否物理删除（默认否）</param>
        //bool Delete(object id, bool isPhysicalDelete = false);

        ///// <summary>
        ///// 可读写
        ///// </summary>
        //IQueryable<T> Table { get; }
        /// <summary>
        /// 只可读数据
        /// </summary>
        //IQueryable<T> TableNoTracking { get; }
    }
}
